package com.nhc.database.dbmodel;

import com.nhc.model.SensorSetInfo;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Transient;

import java.text.DecimalFormat;


@Entity
public class QiyaInfo {

    @Id(autoincrement = true)
    private Long id;
    float sPV = 0;//气压值 hPa-百帕==毫巴
    private double altitude = 0;//海拔高度
    private long datetime = 0; //时间

    private String note = "";//备用 json

    @Transient
    private double up = 0;//累计爬升

    @Generated(hash = 1184208927)
    public QiyaInfo(Long id, float sPV, double altitude, long datetime, String note) {
        this.id = id;
        this.sPV = sPV;
        this.altitude = altitude;
        this.datetime = datetime;
        this.note = note;
    }

    @Generated(hash = 723944669)
    public QiyaInfo() {
    }

    public QiyaInfo(float sPV) {
        this.sPV = sPV;
        this.datetime = System.currentTimeMillis();

//        DecimalFormat df = new DecimalFormat("0.00");
//        df.getRoundingMode();
//        float height_qiya = SensorSetInfo.getInstance().getHeight_qiya();//hpa-毫巴
//        altitude = 44330000 * (1 - (Math.pow((Double.parseDouble(df.format(sPV)) / height_qiya),
//                (float) 1.0 / 5255.0)));

        double height_qiya = SensorSetInfo.getInstance().getHeight_qiya();//hpa-毫巴
        double x2 = sPV / height_qiya;
        double y2 = 1.0 / 5255.0;
        altitude = 44330000.0 * (1 - (Math.pow(x2, y2)));

    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public float getSPV() {
        return this.sPV;
    }

    public void setSPV(float sPV) {
        this.sPV = sPV;
    }

    public double getAltitude() {
        return altitude;
    }

    public void setAltitude(double altitude) {
        this.altitude = altitude;
    }

    public long getDatetime() {
        return this.datetime;
    }

    public void setDatetime(long datetime) {
        this.datetime = datetime;
    }

    public double getUp() {
        return up;
    }

    public void setUp(double up) {
        this.up = up;
    }

    public String getNote() {
        return this.note;
    }

    public void setNote(String note) {
        this.note = note;
    }
}
